using UnityEngine;
using UnityEngine.UI;
using TMPro;

[RequireComponent(typeof(Button))]
public class GameButton : MonoBehaviour
{
    [SerializeField] private TextMeshProUGUI buttonText;
    [SerializeField] private Image iconImage;
    
    private Button button;

    private void Awake()
    {
        button = GetComponent<Button>();
    }

    public void SetupButton(string text, Sprite icon = null)
    {
        if (buttonText != null)
            buttonText.text = text;
            
        if (iconImage != null && icon != null)
            iconImage.sprite = icon;
    }

    public void SetInteractable(bool interactable)
    {
        if (button != null)
            button.interactable = interactable;
    }
}
